#!/usr/bin/env python
#coding=utf-8

"""
import wx

class ScrollbarFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Scrollbar Example',
                size=(300, 200))
        self.scroll = wx.ScrolledWindow(self, -1)
        self.scroll.SetScrollbars(1, 1, 600, 400)
        self.button = wx.Button(self.scroll, -1, "Scroll Me", pos=(50, 20))
        self.Bind(wx.EVT_BUTTON,  self.OnClickTop, self.button)
        self.button2 = wx.Button(self.scroll, -1, "Scroll Back", pos=(500, 350))
        self.Bind(wx.EVT_BUTTON, self.OnClickBottom, self.button2)

    def OnClickTop(self, event):
        self.scroll.Scroll(600, 400)

    def OnClickBottom(self, event):
        self.scroll.Scroll(1, 1)

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = ScrollbarFrame()
    frame.Show()
    app.MainLoop()
"""






import wx

class LeftPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN)

        self.text = parent.GetParent().rightPanel.text
        self.bro = parent.GetParent().rightPanel

        button1 = wx.Button(self, -1, '+', (10, 10))
        button2 = wx.Button(self, -1, '-', (10, 60))

        self.Bind(wx.EVT_BUTTON, self.OnPlus, id=button1.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnMinus, id=button2.GetId())

        self.num = 1
        self.height = 400

    def OnPlus(self, event):
        #value = int(self.text.GetLabel())
        #value = value + 1
        #self.text.SetLabel(str(value))
        tt = self.text.GetLabel()
        print tt
        #self.height += 14
        tt = tt + str(self.num) + ' Move!' + '\n'
        self.num += 1
        if self.num > 9:
            self.bro.SetScrollRate(0, 1)
        self.text.SetLabel(tt)

        #self.bro.posY += 14
        #self.bro.OnClickTop()
        print self.bro.CalcUnscrolledPosition(0, 0)

    def OnMinus(self, event):
        #value = int(self.text.GetLabel())
        #value = value - 1
        #self.text.SetLabel(str(value))
        print 'hahahaha'

class RightPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN|wx.VSCROLL)
        #self.text = wx.StaticText(self, -1, '0', (40, 60))
        self.text = wx.TextCtrl(self,-1,size=(100,100),style=wx.VSCROLL|wx.TE_MULTILINE)


#class RightPanel(wx.Panel):
#    def __init__(self, parent, id):
#        wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN, size=(100, 60))
#        self.scroll = wx.ScrolledWindow(self, -1)
#        self.scroll.SetScrollbars(150, 0, 600, 400)
#        #self.button = wx.Button(self.scroll, -1, "Scroll Me", pos=(50, 20))
#        #self.Bind(wx.EVT_BUTTON,  self.OnClickTop, self.button)
#        #self.button2 = wx.Button(self.scroll, -1, "Scroll Back", pos=(500, 350))
#        #self.Bind(wx.EVT_BUTTON, self.OnClickBottom, self.button2)
#        self.text = wx.StaticText(self, -1, '0', (40, 60))
#
#    def OnClickTop(self, event):
#        self.scroll.Scroll(600, 400)
#
#    def OnClickBottom(self, event):
#        self.scroll.Scroll(1, 1)



#class RightPanel(wx.ScrolledWindow):
#    def __init__(self, parent, id):
#        wx.ScrolledWindow.__init__(self, parent, id, style=wx.BORDER_SUNKEN)
#        self.SetScrollbars(1, 14, 600, 10)
#        self.text = wx.StaticText(self, -1, '', (0, 0))
#        self.posX = 0
#        self.posY = 0
#
#    def OnClickTop(self):
#        self.Scroll(self.posX, self.posY)





class Communicate(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(300, 214))

        panel = wx.Panel(self, -1)
        self.rightPanel = RightPanel(panel, -1)

        leftPanel = LeftPanel(panel, -1)

        hbox = wx.BoxSizer()
        hbox.Add(leftPanel, 1, wx.EXPAND | wx.ALL, 5)
        hbox.Add(self.rightPanel, 1, wx.EXPAND | wx.ALL, 5)

        panel.SetSizer(hbox)
        self.Centre()
        self.Show(True)



if __name__ == '__main__':
    app = wx.App(redirect=True)
    Communicate(None, -1, 'widgets communicate')
    app.MainLoop()





















"""
import wx
import wx.grid



class LoginFrame(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Frame With Button', size=(300, 100))
        panel = wx.Panel(self)
        button = wx.Button(panel, label="Close", pos=(125, 10), size=(50, 50))
        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

    def OnCloseMe(self, event):
        self.Close(True)

    def OnCloseWindow(self, event):
        self.Destroy()








class DataViewerFrame(wx.Frame):
    #rowLabels = ["uno", "dos", "tres", "quatro", "cinco"]
    colLabels = [u"id", u"名字", u"Éú²úÕß", u"Íê³ÉÊ±¼ä", u"Ô¤¼Æ²úÁ¿", u"Ê£ÓàÊýÄ¿"]

    def __init__(self, parent, id):
        wx.Frame.__init__(self, None, title="Grid Headers", size=(580,200))
        self.grid = wx.grid.Grid(self)
        self.grid.CreateGrid(5,6)
        for col in range(6):
            #grid.SetRowLabelValue(row, self.rowLabels[row])
            self.grid.SetColLabelValue(col, self.colLabels[col])
            for row in range(5):
                self.grid.SetCellValue(row, col, "%d" % (row*col))

    def SetData(self, row, col, data):
        if data == '':
            data = raw_input('Please enter the grid value: ')
        self.grid.SetCellValue(row, col, data)




class StaticTextFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Static Text Example',
                size=(400, 300))
        panel = wx.Panel(self, -1)

# 这是一个基本的静态文本
        wx.StaticText(panel, -1, "This is an example of static text",
                (100, 10))

# 指定了前景色和背景色的静态文本
        rev = wx.StaticText(panel, -1, "Static Text With Reversed Colors",
                (100, 30))
        rev.SetForegroundColour('white')
        rev.SetBackgroundColour('black')

# 指定居中对齐的的静态文本
        center = wx.StaticText(panel, -1, "align center", (100, 50),
                (160, -1), wx.ALIGN_CENTER)
        center.SetForegroundColour('white')
        center.SetBackgroundColour('black')

# 指定右对齐的静态文本
        right = wx.StaticText(panel, -1, "align right", (100, 70),
                (160, -1), wx.ALIGN_RIGHT)
        right.SetForegroundColour('white')
        right.SetBackgroundColour('black')

# 指定新字体的静态文本
        str = "You can also change the font."
        text = wx.StaticText(panel, -1, str, (20, 100))
        font = wx.Font(18, wx.DECORATIVE, wx.ITALIC, wx.NORMAL)
        text.SetFont(font)

# 显示多行文本
        wx.StaticText(panel, -1, "Your text\ncan be split\n"
                "over multiple lines\n\neven blank ones", (20,150))

#显示对齐的多行文本
        wx.StaticText(panel, -1, "Multi-line text\ncan also\n"
                "be right aligned\n\neven with a blank", (220,150),
                style=wx.ALIGN_RIGHT)









class App(wx.App):
    def __init__(self, redirect=False, testStr='a'):
        self.testStr = testStr
        wx.App.__init__(self, redirect)

    def OnInit(self):
        print 'OnInit'
        #self.frame = DataViewerFrame(parent=None, id=-1)
        #self.frame.SetData(0, 0, self.testStr)
        self.frame = StaticTextFrame()
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

    def OnExit(self):
        print "OnExit"


if __name__ == '__main__':
    myApp = App()
    myApp.MainLoop()

"""